package memento.example;

public class TestMehtod {

    public static void main(String[] args) {
        // 大战Boss前
        Role role = new Role();
        role.setVit(100);
        role.setAtk(100);
        role.setDef(100);
        System.out.println("战斗前: " + role.toString());

        // 先保存
        RoleStateCretaker stateAdmin = new RoleStateCretaker();
        stateAdmin.setMemento(role.saveState());

        // 大战boss 生命为0
        role.fight();
        System.out.println("战斗输了: " + role.toString());

        // 恢复之前的状态
        role.recoveryState(stateAdmin.getMemento());
        System.out.println("恢复存档: " + role.toString());

    }
}
